<?php

namespace App\Console\Commands;

use App\Model\Logistics\Plan;
use App\Model\Product\Product;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\DB;

class WbzTest extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'wbz:test';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '';


    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        
        \Log::info('任务调度。。。');

        return 1;
        /* Plan::create([
            'product_id'=> 2,
            'qty'=> 1,
            'sku'=> 'test2',
        ]); */

        $res = Plan::get();

        $this->info($res->count());

        $res = Plan::where('id', 1)->update([
            'sku'=> '3333'
        ]);

        $this->info($res);

        return 1;
        //邮件 make:mail
        Mail::to('1039289613@qq.com')->send(
            new \App\Mail\Test(
                ['dat' => 'make:mail 邮件测试']
            )
        );

        dd('任务调度成功');

        return 1;
        $res =  Product::findWithCache([
            1,
            2
        ], 'id');
        Log::info($res);
        return 1;
        $res =  Product::findWithCache([
            'G18MH017K5Y1',
            '234F70563-2',
            'aaaxxx'
        ]);
        Log::info($res);
        return 1;


        $job = new \App\Jobs\Test();
//        dispatch($job);
        #直接 handle 相当于同步
/*        $res = $job->handle('wu buze');
        \Log::info($res);
        \Log::info('next');*/

        # ::dispatch(构造方法)
        \App\Jobs\PostcastJob::dispatch('php 是世界上最好的语言');


    }
}
